package cn.stormling.note2.job;

import org.quartz.*;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author stormling
 * Job 实例
 */
public class QuartzHelloJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        // 当前时间
        Date date = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss");
        String dateStr = dateFormat.format(date);
        System.out.println("任务名称："+jobExecutionContext.getJobDetail().getKey().getName());
        System.out.println("任务组别："+jobExecutionContext.getJobDetail().getKey().getGroup());
        // 工作内容
        System.out.println("正在进行数据备份任务的定时执行，执行时间：" + dateStr);

        //Job 传值
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        System.out.println("任务数据的参数值：" +jobDataMap.get("message"));
    }

}
